<?php
Yii::import('zii.widgets.CMenu');

/**
 * @author ElisDN <mail@elisdn.ru>
 * @link http://www.elisdn.ru
 */

class BackendMenu extends CMenu
{
    public $iconsPath = '/';
    public $iconsSize = '10';
    public $glyphiconsSize = '10';
    public $faiconsSize = '10';
    public $iconsColor = '#000000';

    protected function renderMenuItem($item)
    {
        if(!empty($item['glyphicon']))
            $icon =  CHtml::tag('span',array('class'=>'glyphicon glyphicon-'.$item['glyphicon'],'style'=>'font-size:'.$this->glyphiconsSize.'px ;color:'.$this->iconsColor),'');
        elseif(!empty($item['faicon']))
            $icon = CHtml::tag('i',array('class'=>'fa fa-'.$item['faicon'],'style'=>'font-size:'.$this->faiconsSize.'px; color:'.$this->iconsColor),'');
        elseif(!empty($item['icon']))
            $icon =  CHtml::image($this->iconsPath . $item['icon'], $item['label'],array('style'=>'height:'.$this->iconsSize.'px'));
        else
            $icon = '';

        $options = isset($item['linkOptions']) ? $item['linkOptions'] : array();

        if(isset($item['facaret']))
            $caret = CHtml::tag('i',array('class'=>'fa fa-'.$item['facaret'].' pull-right'),'');
        else
            $caret = '';

        if(isset($item['selected']))
            $selected = CHtml::tag('span',array('class'=>$item['selected']),'');
        else
            $selected = '';


        if(isset($item['url']))
        {
            if ($this->linkLabelWrapper !== null)
                $label = '<' . $this->linkLabelWrapper . '>' . $item['label'] . '</' . $this->linkLabelWrapper . '>';
            else
                $label = $item['label'];

            return  CHtml::link($icon.$caret.'&nbsp'.$label.$selected, $item['url'], $options);
        }
        else
            return $icon . CHtml::tag('span', $options, $item['label']);
    }
}